package servlet;

import pojo.Brand;
import service.BrandService;
import service.BrandService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SelectAllServlet", value = "/selectAll")
public class SelectAllServlet extends HttpServlet {
    private BrandService  brandService = new BrandService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.调用BrandService 的y selectAll()方认进行业务逻辑处理，并接收返画的结窠
        List<Brand> brandList =brandService.selectAll();
        // 2.返回的结采存储到’request域对象中
        request.setAttribute(  "brands" , brandList);
        //3.跳转到brand.jsp页密进行数数的展示
        request.getRequestDispatcher(  "/brand.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);

    }
}